﻿Imports KOR.Helpers
Imports KOR.Support
Imports Telerik.Web.UI
Imports System.IO
Imports System.Drawing

Public Class Home
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadProducts()
        End If
    End Sub

    Private Sub LoadProducts()
        Try

            Using reader As IDataReader = BL.Products.GetAllProducts()
                Me.divProducts_curosel.InnerHtml += "<div class=' col-md-3'>"
                While reader.Read

                    Me.divProducts_curosel.InnerHtml += "<div class='single-product'>"
                    Me.divProducts_curosel.InnerHtml += " <div class='product-img'>"
                    Me.divProducts_curosel.InnerHtml += "  <a href='#'>"
                    Using rd As IDataReader = BL.Files.GetFiles(ValueOrDefault(reader("FileIds"), ""))
                        If rd.Read Then
                            Me.divProducts_curosel.InnerHtml += "   <img class='primary-image' src='" + ValueOrDefault(rd("FilePath"), "").ToString + "' alt=''/>"
                        End If
                    End Using

                    Me.divProducts_curosel.InnerHtml += "  </a>"
                    Me.divProducts_curosel.InnerHtml += " </div>"
                    Me.divProducts_curosel.InnerHtml += " <div class='product-content'>"
                    Me.divProducts_curosel.InnerHtml += "  <div class='price-box'>"
                    Me.divProducts_curosel.InnerHtml += "   <span class='special-price'>$" + ValueOrDefault(reader("Price"), "").ToString + "</span>"
                    Me.divProducts_curosel.InnerHtml += "  </div>"
                    Me.divProducts_curosel.InnerHtml += "  <h2 class='product-name'><a href='#'>" + ValueOrDefault(reader("ProductName"), "") + "</a></h2>"
                    Me.divProducts_curosel.InnerHtml += "  <div class='pro-rating'>"
                    Me.divProducts_curosel.InnerHtml += "   <div class='pro_one'>"
                    Me.divProducts_curosel.InnerHtml += "    <a href='#'><i class='fa fa-star-o'></i></a>"
                    Me.divProducts_curosel.InnerHtml += "    <a href='#'><i class='fa fa-star-o'></i></a>"
                    Me.divProducts_curosel.InnerHtml += "    <a href='#'><i class='fa fa-star-o'></i></a>"
                    Me.divProducts_curosel.InnerHtml += "    <a href='#'><i class='fa fa-star-o'></i></a>"
                    Me.divProducts_curosel.InnerHtml += "   </div>"
                    Me.divProducts_curosel.InnerHtml += "   <div class='pro_two'>"
                    Me.divProducts_curosel.InnerHtml += "    <a href='#'><i class='fa fa-star-o'></i></a>"
                    Me.divProducts_curosel.InnerHtml += "   </div>"
                    Me.divProducts_curosel.InnerHtml += "  </div>"
                    Me.divProducts_curosel.InnerHtml += " </div>"
                    Me.divProducts_curosel.InnerHtml += "</div>"
                End While
                Me.divProducts_curosel.InnerHtml += "</div>"
            End Using
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Function LoadPictures(Ids As String)
        Return BL.Files.GetFiles(Ids)
    End Function
End Class